/*
** 2629.c
** 
** Made by (seakage2h)
** Login   <seakage2h@seakage2h-ubuntu>
** 
** Started on  Thu Oct 16 21:15:44 2008 seakage2h
** Last update Sun May 12 01:17:25 2002 Speed Blue
*/

/* #include "2629.h" */
#include <stdio.h>

int main()
{
     int str[2][123];
     char s;
     char cur;
     for(cur = 97; cur < 123; cur++)
	  str[0][cur] = str[1][cur] = 0;
     
     s = 0;
     while((cur = getchar()) != EOF)
	  if (cur != '\n')
	       str[s][cur]++;
	  else
	       if (s == 0)	/* first string finished */
		    s = 1;
	       else{		/* we've got two strings, now compute */
		    for(cur = 97; cur < 123; cur++){
			 /* use str[0] to store common alphabets */
			 if (str[1][cur] < str[0][cur])
			      str[0][cur] = str[1][cur];
			 for(s = 0; s < str[0][cur]; s++)
			      putchar(cur);
		    }
		    putchar('\n');
		    s = 0;
		    /* done. reset to zeros */
		    for(cur = 97; cur < 123; cur++)
			 str[0][cur] = str[1][cur] = 0;
	       }
	       
     return 0;
}
